home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blitzblank / sources / bb.lines < prev    next >
Text File  |  1993-09-17  |  7KB  |  323 lines

  1. ;BB.Lines - Blanker-module for BlitzBlank
  2. ;Copyright 1993 by Thomas Boerkel
  3.  
  4. CloseEd
  5. NoCli
  6.  
  7. NEWTYPE.line
  8. x1.w
  9. y1
  10. x2
  11. y2
  12. c
  13. End NEWTYPE
  14.  
  15. NEWTYPE.spritedata
  16. a.w
  17. b
  18. c
  19. d
  20. e
  21. f
  22. End NEWTYPE
  23.  
  24. NEWTYPE.tags
  25. a.l
  26. b
  27. c
  28. d
  29. e
  30. f
  31. End NEWTYPE
  32.  
  33. DEFTYPE.spritedata *sprdata
  34. DEFTYPE.SimpleSprite spr
  35. DEFTYPE.Screen *myscreen
  36. DEFTYPE.NewScreen newscreen
  37. DEFTYPE.Message *msg
  38. DEFTYPE.MsgPort *port
  39. DEFTYPE.tags tags
  40. DEFTYPE.l
  41.  
  42. Statement stringborder{x,y,w,h}
  43. Wline x+1,y+h+2,x+1,y,x+w+8,y,1
  44. Wline x+w+10,y-1,x+w+10,y+h+4,x-1,y+h+4,1
  45. Wline x,y+h+3,x,y,1
  46. Wline x+w+11,y-1,x+w+11,y+h+4,1
  47. Wline x-1,y+h+3,x-1,y-1,x+w+10,y-1,2
  48. Wline x+w+9,y,x+w+9,y+h+3,x+1,y+h+3,2
  49. Wline x-2,y+h+4,x-2,y-1,2
  50. Wline x+w+8,y+1,x+w+8,y+h+2,2
  51. End Statement
  52.  
  53.  
  54. al=0
  55. Select Par$(1)
  56.   Case "BLANK"
  57.  
  58.     name$="BB.BlankModule"+Chr$(0)
  59.     *port=CreateMsgPort_()
  60.     *port\mp_Node\ln_Name=&name$
  61.     *port\mp_Node\ln_Pri=1
  62.     AddPort_ *port
  63.  
  64.     SetTaskPri_ FindTask_(0),Val(Par$(8))
  65.     *sprdata=AllocMem_(SizeOf.spritedata,#MEMF_CHIP|#MEMF_CLEAR)
  66.  
  67.     Gosub readconfig
  68.  
  69.     width=Val(Par$(2))
  70.     height=Val(Par$(3))
  71.     mode=Val(Par$(4))
  72.     monitor=Val(Par$(5))
  73.     depth=Val(Par$(6))
  74.     colors=2^depth
  75.     title$="BB.Lines.Screen"+Chr$(0)
  76.     newscreen\LeftEdge=0,0,width,height,depth
  77.     newscreen\ViewModes=0,#CUSTOMSCREEN|#SCREENBEHIND,0,&title$
  78.     tags\a=#SA_DisplayID
  79.     tags\b=$10000*monitor+mode
  80.     tags\c=0
  81.     *myscreen=OpenScreenTagList_(newscreen,tags)
  82.     If *myscreen
  83.       *vp=*myscreen\ViewPort
  84.       *rp=*myscreen\RastPort
  85.       SetRGB4_ *vp,0,0,0,0
  86.       SetRGB4_ *vp,1,15,0,0
  87.  
  88.       If colors>2
  89.         SetRGB4_ *vp,2,0,0,15
  90.         SetRGB4_ *vp,3,0,15,0
  91.         If colors>4
  92.           SetRGB4_ *vp,4,0,5,10
  93.           SetRGB4_ *vp,5,15,3,8
  94.           SetRGB4_ *vp,6,15,5,15
  95.           SetRGB4_ *vp,7,5,15,8
  96.           If colors>8
  97.             SetRGB4_ *vp,8,10,5,0
  98.             SetRGB4_ *vp,9,0,15,5
  99.             SetRGB4_ *vp,10,15,7,0
  100.             SetRGB4_ *vp,11,0,7,15
  101.             SetRGB4_ *vp,12,8,15,3
  102.             SetRGB4_ *vp,13,15,10,5
  103.             SetRGB4_ *vp,14,7,0,15
  104.             SetRGB4_ *vp,15,3,8,15
  105.             If colors>16
  106.               For i=16 To colors-1
  107.                 SetRGB4_ *vp,i,Rnd(13)+3,Rnd(13)+3,Rnd(13)+3
  108.               Next i
  109.             EndIf
  110.           EndIf
  111.         EndIf
  112.       EndIf
  113.  
  114.       SetAPen_ *rp,0
  115.       RectFill_ *rp,0,0,width-1,height-1
  116.       ScreenToFront_ *myscreen
  117.  
  118.       w=3
  119.       s=1
  120.       co=1
  121.       ch=al/colors
  122.       If ch=0 Then ch=1
  123.       Delay_ 10
  124.       VWait
  125.       ChangeSprite_ 0,spr,*sprdata
  126.  
  127.       dx1=Rnd(w)+s
  128.       dy1=Rnd(w)+s
  129.       dx2=Rnd(w)+s
  130.       dy2=Rnd(w)+s
  131.       Dim li.line(al)
  132.       li(0)\x1=Rnd(width)
  133.       li(0)\y1=Rnd(height)
  134.       li(0)\x2=Rnd(width)
  135.       li(0)\y2=Rnd(height)
  136.  
  137.  
  138.       For i=1 To al-1
  139.         li(i)\x1=li(i-1)\x1+dx1
  140.         li(i)\y1=li(i-1)\y1+dy1
  141.         li(i)\x2=li(i-1)\x2+dx2
  142.         li(i)\y2=li(i-1)\y2+dy2
  143.         Gosub check
  144.         fdummy.f=i/ch
  145.         If fdummy=Int(i/ch)
  146.           co+1:If co>colors-1 Then co=1
  147.         EndIf
  148.         SetAPen_ *rp,co
  149.         Move_ *rp,li(i)\x1,li(i)\y1
  150.         Draw_ *rp,li(i)\x2,li(i)\y2
  151.         *msg=GetMsg_(*port)
  152.         If *msg
  153.           i=al-1
  154.         EndIf
  155.       Next i
  156.  
  157.       If *msg=0
  158.  
  159.         i=0
  160.         v=al-1
  161.  
  162.         Repeat
  163.           SetAPen_ *rp,0
  164.           Move_ *rp,li(i)\x1,li(i)\y1
  165.           Draw_ *rp,li(i)\x2,li(i)\y2
  166.           li(i)\x1=li(v)\x1+dx1
  167.           li(i)\y1=li(v)\y1+dy1
  168.           li(i)\x2=li(v)\x2+dx2
  169.           li(i)\y2=li(v)\y2+dy2
  170.           Gosub check
  171.           fdummy.f=i/ch
  172.           If fdummy=Int(i/ch)
  173.             co+1:If co>colors-1 Then co=1
  174.           EndIf
  175.           SetAPen_ *rp,co
  176.           Move_ *rp,li(i)\x1,li(i)\y1
  177.           Draw_ *rp,li(i)\x2,li(i)\y2
  178.           i+1
  179.           If i>al-1
  180.             i=0
  181.             dx1=Sgn(dx1)*(Rnd(w)+s)
  182.             dy1=Sgn(dy1)*(Rnd(w)+s)
  183.             dx2=Sgn(dx2)*(Rnd(w)+s)
  184.             dy2=Sgn(dy2)*(Rnd(w)+s)
  185.           EndIf
  186.           v+1
  187.           If v>al-1 Then v=0
  188.           *msg=GetMsg_(*port)
  189.         Until *msg
  190.  
  191.       EndIf
  192.  
  193.       CloseScreen_ *myscreen
  194.     EndIf
  195.     FreeMem_ *sprdata,SizeOf.spritedata
  196.     RemPort_ *port
  197.     DeleteMsgPort_ *port
  198.  
  199.  
  200.   Case "INFO"
  201.  
  202.     title$="Lines"+Chr$(0)
  203.     reqtext$="Lines - Module for BlitzBlank"+Chr$(10)
  204.     reqtext$+Chr$(169)+" 1993 by Thomas Brkel and Jrgen Denner"+Chr$(10)+Chr$(10)
  205.     reqtext$+"You see wild lines on the screen."+Chr$(10)+Chr$(10)
  206.     reqtext$+"Choose the number of lines in the config-window."+Chr$(0)
  207.     gadget$="OK"+Chr$(0)
  208.  
  209.     easy.EasyStruct\es_StructSize=SizeOf.EasyStruct
  210.     easy\es_Title=&title$
  211.     easy\es_TextFormat=&reqtext$
  212.     easy\es_GadgetFormat=&gadget$
  213.  
  214.     EasyRequestArgs_ 0,easy,0,0
  215.  
  216.   Case "CONFIG"
  217.     *myscreen=LockPubScreen_(0)
  218.     width=*myscreen\Width
  219.     height=*myscreen\Height
  220.     font=*myscreen\Font\ta_YSize
  221.     Gosub readconfig
  222.     WbToScreen 0
  223.     BorderPens 0,0
  224.     StringGadget 0,100,25,0,0,4,40
  225.     Window 0,width/2-90,height/2-25,180,50,$100e,"Lines",1,2,0
  226.     stringborder{100,25,40,8}
  227.     WColour 2
  228.     WLocate 32,24-font
  229.     Print "Lines:"
  230.     WLocate 32,24-font+8
  231.     Print "(5-200)"
  232.     SetString 0,0,Str$(al)
  233.     ActivateString 0,0
  234.     Repeat
  235.       ev=WaitEvent
  236.     Until ev=$200 OR ev=$40
  237.     al=Val(StringText$(0,0))
  238.     Free Window 0
  239.     Gosub writeconfig
  240.     UnlockPubScreen_ 0,*myscreen
  241. End Select
  242.  
  243. End
  244.  
  245.  
  246. .check
  247. If li(i)\x1>width-1 OR li(i)\x1<0
  248.   dx1=-dx1
  249.   li(i)\x1+2*dx1
  250. EndIf
  251. If li(i)\y1>height-1 OR li(i)\y1<0
  252.   dy1=-dy1
  253.   li(i)\y1+2*dy1
  254. EndIf
  255. If li(i)\x2>width-1 OR li(i)\x2<0
  256.   dx2=-dx2
  257.   li(i)\x2+2*dx2
  258. EndIf
  259. If li(i)\y2>height-1 OR li(i)\y2<0
  260.   dy2=-dy2
  261.   li(i)\y2+2*dy2
  262. EndIf
  263. Return
  264.  
  265. .readconfig
  266. path$=Par$(9)
  267. For i=10 To NumPars
  268.   path$=path$+" "+Par$(i)
  269. Next i
  270. If ReadFile(0,path$+"BB.Modules.config")
  271.   FileInput 0
  272.   While NOT Eof(0)
  273.     If Edit$(100)="*** Lines ***"
  274.       al=Val(Edit$(5))
  275.     EndIf
  276.   Wend
  277.   DefaultInput
  278.   CloseFile 0
  279. EndIf
  280. Gosub checkval
  281. Return
  282.  
  283.  
  284. .writeconfig
  285. Gosub checkval
  286. If ReadFile(0,path$+"BB.Modules.config")
  287.   If WriteFile(1,path$+"BB.Modules.temp")
  288.     FileInput 0
  289.     FileOutput 1
  290.     While NOT Eof(0)
  291.       f$=Edit$(100)
  292.       If f$="*** Lines ***"
  293.         Repeat
  294.           f2$=Edit$(100)
  295.         Until Eof(0) OR Left$(f2$,3)="***"
  296.         If NOT Eof(0) Then NPrint f2$
  297.       Else
  298.         NPrint f$
  299.       EndIf
  300.     Wend
  301.     CloseFile 1
  302.   EndIf
  303.   CloseFile 0
  304. EndIf
  305. KillFile path$+"BB.Modules.config"
  306. f$=path$+"BB.Modules.temp"+Chr$(0)
  307. f2$=path$+"BB.Modules.config"+Chr$(0)
  308. Rename_ &f$,&f2$
  309. If OpenFile(0,path$+"BB.Modules.config")
  310.   FileOutput 0
  311.   FileSeek 0,Lof(0)
  312.   NPrint "*** Lines ***"
  313.   NPrint al
  314.   CloseFile 0
  315. EndIf
  316. Return
  317.  
  318. .checkval
  319. If al<5 Then al=50
  320. If al>200 Then al=50
  321. Return
  322.  
  323.